using AutoMapper;
using B.S.Databasic.Api.Read.Application.Command.Permission;
using B.S.Databasic.Api.Read.Application.Command.Role;
using B.S.Databasic.Domain.RBAC;

namespace B.S.Databasic.Api.Read.Profiles
{
    public class RoleProfile : Profile
    {
        public RoleProfile()
        {
            // Role
            CreateMap<RoleModel, RoleDto>()
                .ForMember(dest => dest.PermissionNames, opt => opt.Ignore())
                .ForMember(dest => dest.PermissionIds, opt => opt.Ignore());

            // Permission
            CreateMap<PermissionModel, PermissionTreeDTO>()
                .ForMember(d => d.Id, c => c.MapFrom(e => e.Id))
                .ForMember(d => d.Name, c => c.MapFrom(e => e.PermissionName));
        }
    }
}